<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>触摸事件</title>
    <style>
        *{
            padding:0;
            margin: 0;
        }
        #box{
            width: 100%; 
            height: 200px;
            background: #ccc;
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script>
        //获取元素
        let box = document.querySelector("#box");

        //绑定事件  on 当...时候   touch 触摸  start 开始
        box.ontouchstart = function(){
            console.log('touchstart 事件触发');
        }

        box.ontouchmove = function(){
            console.log('touchmove 事件触发');
        }

        box.addEventListener("touchend", function(){
            console.log('touchend 事件触发');
        });

        //触摸被打断的事件
        box.addEventListener("touchcancel", function(){
            console.log('触摸被打断了...');
        });

        setTimeout(() => {
            alert('主人, 那家伙又来电话啦!!');
        }, 3000);

    </script>
</body>
</html>